package StudyCode.summary.mycollection;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UnserializeList {
	public static <T> List<T> unserializList(String path) {
		File file = new File(path);
		List<T> collections = new ArrayList<T>();
		ObjectInputStream objectInputStream = null;
		try {
			InputStream inputStream = new FileInputStream(file);
			objectInputStream = new ObjectInputStream(inputStream);
			while (true) {
				try {
					T t = (T) objectInputStream.readObject();
					collections.add(t);
				} catch (EOFException e) {
					break;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				objectInputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return collections;
	}
}
